package Threadprojects.pro3_bestMatching.data.grounp;

import Threadprojects.pro3_bestMatching.data.util.BestMatchingData;
import Threadprojects.pro3_bestMatching.data.util.ReadData;

import java.io.IOException;
import java.util.List;
import java.util.concurrent.*;

public class BestMatchingCalculation {



    public static void getBestMatchingWords(    String word,List<String> words)  {
        try {
            ThreadPoolExecutor tpe=new ThreadPoolExecutor(
                    10,
                    16,
                    5,
                    TimeUnit.SECONDS,
                    new ArrayBlockingQueue<>(2000)
            );
            BestMatchingTask task = new BestMatchingTask(word, words, 0, words.size());
            FutureTask<BestMatchingData> futureTask = new FutureTask<>(task);
            tpe.submit(futureTask);
            BestMatchingData data = futureTask.get();
            System.out.println(data.getWords());
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    }
}
